//pwm_servo_test.cpp
//Erik Wright
//2-26-2014

/*
This cpp file is a test on the pwm_servo class.  It runs
through functions and produces output to the standard
output.  

*/


#include "pwm_servo.h"
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <cmath>
using namespace std;



int main()
{
	srand(time(NULL));	//seed the pseudo random number generator

	int len_a = 5;
	int len_b = 5;

	
	cout<<"============ Creating New Servo Channels ==========="<<endl;
	pwm_servo servo_a;	//default constructor
	pwm_servo servo_b;
	data_node* spawnpoint;

	//display initialized servo lists
	cout<<"servo_a: ";
	servo_a.display();
	cout<<"servo_b: ";
	servo_b.display();

	//populate servo_a
	for(int i=0; i< len_a; i++)
	{
		spawnpoint = new data_node;
		servo_a.insert_at_end(spawnpoint);
	}

	//populate servo_b
	for(int j=0; j< len_b; j++)
	{
		spawnpoint = new data_node();
		servo_b.insert_at_end(spawnpoint);
	}


	//display population
	cout<<"servo_a: ";
	servo_a.display();
	cout<<"servo_b: ";
	servo_b.display();
	
	//perform different twists
	cout<<"======== Binary Twist Operation ========"<<endl;
	servo_a.binary_twist(servo_b, true);

	//redisplay population	
	cout<<"servo_a: ";
	servo_a.display();
	cout<<"servo_b: ";
	servo_b.display();

	cout<<"======== Random Binary Twist Operation ======="<<endl;
	servo_a.binary_twist_rand(servo_b,true);
	
	//redisplay population	
	cout<<"servo_a: ";
	servo_a.display();
	cout<<"servo_b: ";
	servo_b.display();



	//delete dynamically allocated memory

	cout<<"------------------ End of Program ----------------"<<endl;
	return 0;
	
}

